package menu;

import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.Scanner;

/**
 * 设置界面: 设置音乐
 * 非核心
 * 负责人:白泽
 */

public class SetMenu {

    public SetMenu(){
        System.out.println("----------------------------");
        System.out.println("*********  游戏设置: *********");
        System.out.println("******** 按 1 开启音乐 ********");
        //System.out.println("******** 1. 开启音乐 *********");
        //System.out.println("******** 2. 关闭音乐 *********");
        System.out.println("----------------------------");
    }

    public void start(){

        File musicFile = new File("src\\menu\\方案一.wav");
        URI uri = musicFile.toURI();
        URL url = null;
        try {
            url = uri.toURL();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        AudioClip clip = Applet.newAudioClip(url);

        Scanner scanner = new Scanner(System.in);
        int input = 0;
        do{
            System.out.print("请输入你的选择:>");
            input = scanner.nextInt();
            switch (input){
                case 1:
                    clip.play();
                    new StartMenu().start();
                    break;
                case 2:
                    clip.stop();
                    new StartMenu().start();
                    break;
                case 0:
                    System.out.println("游戏结束");
                    System.exit(0);
                default:
                    System.out.println("输入错误, 请重新输入!");
            }
        }while (true);
    }
}
